package com.sinosoft.msf.base.supplier.aspect;

import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

@Aspect
@Component
@Slf4j
public class ApiLogAop {


//    @Pointcut("execution(* com.sinosoft.msf.base.supplier.controller..*.*(..))")
//    public void apiLogApoCut(){}
//
//    @Around("apiLogApoCut()")
//    public Object log(ProceedingJoinPoint joinPoint) throws Throwable {
//        long start = System.currentTimeMillis();
//        String methodExplain = joinPoint.getSignature().getName();
//        String requestData = "";
//        if (joinPoint.getArgs().length > 0) {
//            requestData = JSON.toJSONString(joinPoint.getArgs());
//        }
//        log.info("[{} start requestData= {}]", methodExplain, requestData);
//        Object result = joinPoint.proceed();
//
//        long executionTime = System.currentTimeMillis() - start;
//        String responseData = "";
//        if (result != null) {
//            responseData = JSON.toJSONString(result);
//        }
//        log.info("[{} end executionTime= {} responseData = {}]", methodExplain, executionTime, responseData);
//        return result;
//    }
}
